const { toArray } = require("../utils/transform_tool");
const { BaseCommand } = require("./base");

class AssertCommand extends BaseCommand {
    async execute() {
        const missingKeys = [];
        toArray(this.selfData.key).forEach((key) => {
            if (!this.getDataByKey(key)) missingKeys.push(key);
        });
        if (missingKeys.length) {
            throw `${missingKeys.map((v) => `"${v}"`).join(",")} 参数不存在(${missingKeys.length})`;
        }
    }
}

module.exports = {
    AssertCommand,
};
